﻿@using FwProject.Core.SettlementInfoModel
@using FwProject.Authorization
@{
    ViewBag.Title = "收押金";
}
@section styles{
    <link href="~/Theme/css/plugins/iCheck/custom.css" rel="stylesheet">
    <link href="~/Theme/css/plugins/datapicker/datepicker3.css" rel="stylesheet">
    <style type="text/css">
        .input-group[class*=col-] {
            padding: 0 15px;
        }

        .checked {
            position: absolute;
            top: 3px;
            left: 220px;
            height: 87px;
            width: 141px;
            background: url('/images/checked.gif') left top no-repeat;
            z-index: 9999;
        }
    </style>
}
<div class="row wrapper wrapper-content animated fadeInRight">
    <div class="col-sm-12">
        <div class="ibox float-e-margins">
            <div class="ibox-title">
                <h5>@ViewBag.Title</h5>
                <div class="ibox-tools">
                    <button class="btn btn-primary btn-xs" id="btnSave">保存</button>
                    <button class="btn btn-primary btn-xs" id="btnSubmit">提交</button>
                </div>
            </div>
            <div class="ibox-content" style="height:700px">
                <div class="row m-b-sm m-t-sm">
                    <form class="form-horizontal" id="form" asp-controller="Deposit" asp-action="Collect" data-ajax="true" data-ajax-method="Post" data-ajax-mode="replace" data-ajax-success="ReloadAjaxCallbackgoback" data-ajax-failure="FailureAjaxCallback">
                        <input type="hidden" name="FactoryinfoId" value="@ViewBag.FactoryinfoId" />
                        <input type="hidden" name="DepositStatus" id="DepositStatus" value="0" />
                        <div class="form-group">
                            <div class="col-md-6">
                                <label class="control-label col-md-3">单号：</label>
                                <div class="input-group">
                                    <input type="text" name="CreationNumber" class="input-sm form-control" value="系统自动生成" readonly="readonly">
                                </div>
                            </div>
                            <div class="col-md-6">
                                <label class="control-label col-md-3">日期：</label>
                                <div class="input-group">
                                    <input type="text" name="DepositTime" id="DepositTime" class="input-sm form-control" value="@DateTime.Now.ToString("yyyy-MM-dd")">
                                </div>
                            </div>
                        </div>
                        <div class="form-group">
                            <div class="col-md-6">
                                <label class="control-label col-md-3">餐厅：</label>
                                <div class="input-group" style="width:162px">
                                    <input type="hidden" name="RestaurantId" id="RestaurantId" />
                                    <input type="text" id="dropdown-restaurantid" class="form-control" onblur="blurEmpty()" style="width:162px">
                                    <div class="input-group-btn">
                                        <button type="button" class="btn btn-white dropdown-toggle" data-toggle="dropdown" style="line-height:1.455;padding:6px 12px;">
                                            <span class="caret"></span>
                                        </button>
                                        <ul class="dropdown-menu dropdown-menu-right" role="menu" style="z-index: 9999;"></ul>
                                    </div>
                                </div>
                            </div>
                            <div class="col-md-6">
                                <label class="control-label col-md-3">押金金额：</label>
                                <div class="input-group">
                                    <input type="text" name="Money" class="input-sm form-control" value="0.00">
                                </div>
                            </div>
                        </div>
                        <div class="form-group">
                            <div class="col-md-6">
                                <label class="control-label col-md-3">收款账户：</label>
                                <div class="input-group" style="width:162px">
                                    <input type="hidden" name="CapitalAccountId" id="CapitalAccountId" />
                                    <input type="text" id="dropdown-capitalaccountid" class="form-control" onblur="blurEmpty1()" style="width:162px">
                                    <div class="input-group-btn">
                                        <button type="button" class="btn btn-white dropdown-toggle" data-toggle="dropdown" style="line-height:1.455;padding:6px 12px;">
                                            <span class="caret"></span>
                                        </button>
                                        <ul class="dropdown-menu dropdown-menu-right" role="menu" style="z-index: 9999;"></ul>
                                    </div>
                                </div>
                            </div>

                            <div class="col-md-6">
                                <label class="control-label col-md-3">经办人：</label>
                                @*<div class="input-group" style="width:162px">
                                        <input type="hidden" name="AgentPeoperUserId" id="AgentPeoperUserId" />
                                        <input type="text" id="dropdown-agentpeoperuserid" class="form-control" onblur="blurEmpty2()" style="width:162px">
                                        <div class="input-group-btn">
                                            <button type="button" class="btn btn-white dropdown-toggle" data-toggle="dropdown" style="line-height:1.455;padding:6px 12px;">
                                                <span class="caret"></span>
                                            </button>
                                            <ul class="dropdown-menu dropdown-menu-right" role="menu" style="z-index: 9999;"></ul>
                                        </div>
                                    </div>*@
                                <div class="input-group">
                                    <input type="hidden" name="AgentPeoperUserId" value="@ViewBag.AgentPeoperUserId" />
                                    <input type="text" name="AgentPeoper" class="input-sm form-control" value="@ViewBag.AgentPeoper" readonly="readonly">
                                </div>
                            </div>
                        </div>
                        <div class="form-group">
                            <div class="col-md-6">
                                <label class="control-label col-md-3">备注：</label>
                                <div class="input-group">
                                    <textarea class="form-control" style="width: 600px" name="RemarkContent"></textarea>
                                </div>
                            </div>
                        </div>
                    </form>
                </div>
            </div>
        </div>
    </div>
</div>
@section scripts{
    <script src="~/Theme/js/content.min.js?v=1.0.0"></script>
    <script src="~/Theme/js/plugins/iCheck/icheck.min.js"></script>
    <script src="~/Theme/js/plugins/datapicker/bootstrap-datepicker.js"></script>
    <script src="~/Theme/js/plugins/suggest/bootstrap-suggest2014.js"></script>
    <script src="~/js/DateComm.js"></script>
    <script>
        $(document).ready(function () {

            $.getJSON("/Deposit/GetRestaurantData").done(function (data) {
                CommonAjaxCallback(data, function () {
                    bindSuggest(data.result);
                }, null);
            }).fail(function () {
                layer.msg('连接超时，获取餐厅失败！', {
                    icon: 2,
                    time: 2000
                });
            });

            $.getJSON("/Deposit/GetSettlementAccount").done(function (data) {
                CommonAjaxCallback(data, function () {
                    bindSuggest1(data.result);
                }, null);
            }).fail(function () {
                layer.msg('连接超时，获取账户失败！', {
                    icon: 2,
                    time: 2000
                });
            });

            $.getJSON("/Deposit/GetAgentPeoperData").done(function (data) {
                CommonAjaxCallback(data, function () {
                    bindSuggest2(data.result);
                }, null);
            }).fail(function () {
                layer.msg('连接超时，获取经办人失败！', {
                    icon: 2,
                    time: 2000
                });
            });

            $('#btnSave').click(function () {
                layer.confirm('是否确认保存?', { icon: 3, title: '提示' }, function (index) {
                    $('#form').submit();
                    layer.close(index);
                });
            });

            $("#btnSubmit").click(function () {
                layer.confirm('是否确认提交审核?', { icon: 3, title: '提示' }, function (index) {
                    $("#DepositStatus").val(1);
                    $('#form').submit();
                    layer.close(index);
                });
            });

            $('#DepositTime').datepicker({
                todayBtn: "linked",
                autoclose: true,
                todayHighlight: true,
                endDate: new Date()

            });
        });

        function bindSuggest(data) {
            if ($("#dropdown-restaurantid") != undefined) {
                $role = $("#dropdown-restaurantid").bsSuggest({
                    effectiveFields: ["restaurantName"],
                    effectiveFieldsAlias: { "restaurantName": "餐厅" },
                    searchFields: ["restaurantName"],
                    clearable: true,
                    getDataMethod: "data",
                    //url: "/Users/GetSuggestData?type=司机类型&keyword=",
                    data: { value: data },
                    idField: "id",
                    keyField: "restaurantName",
                }).on('onDataRequestSuccess', function (e, result) {
                    console.log('onDataRequestSuccess: ', result);
                }).on('onSetSelectValue', function (e, keyword, data) {
                    $("#RestaurantId").val(data.id);
                    $.post("/Deposit/GetRestaurantByDeposit/" + data.id, function (d) {
                        if (d.result)
                            window.location.href = "/Deposit/RestaurantByDepositinfo/" + data.id;
                    });
                    console.log('onSetSelectValue: ', keyword, data);
                }).on('onUnsetSelectValue', function () {
                    console.log('onUnsetSelectValue');
                });
            }
        }
        function blurEmpty() {
            var cityObj = $("#dropdown-restaurantid");
            var DriverId = $("#RestaurantId");
            if (cityObj.val() == "") {
                DriverId.attr("value", "");
            }
        }

        function bindSuggest1(data) {
            if ($("#dropdown-capitalaccountid") != undefined) {
                $role = $("#dropdown-capitalaccountid").bsSuggest({
                    effectiveFields: ["name"],
                    effectiveFieldsAlias: { "name": "餐厅" },
                    searchFields: ["name"],
                    clearable: true,
                    getDataMethod: "data",
                    //url: "/Users/GetSuggestData?type=司机类型&keyword=",
                    data: { value: data },
                    idField: "id",
                    keyField: "name",
                }).on('onDataRequestSuccess', function (e, result) {
                    console.log('onDataRequestSuccess: ', result);
                }).on('onSetSelectValue', function (e, keyword, data) {
                    $("#CapitalAccountId").val(data.id);


                    console.log('onSetSelectValue: ', keyword, data);
                }).on('onUnsetSelectValue', function () {
                    console.log('onUnsetSelectValue');
                });
            }
        }
        function blurEmpty1() {
            var cityObj = $("#dropdown-capitalaccountid");
            var DriverId = $("#CapitalAccountId");
            if (cityObj.val() == "") {
                DriverId.attr("value", "");
            }
        }

        function bindSuggest2(data) {
            if ($("#dropdown-agentpeoperuserid") != undefined) {
                $role = $("#dropdown-agentpeoperuserid").bsSuggest({
                    effectiveFields: ["name"],
                    effectiveFieldsAlias: { "name": "姓名" },
                    searchFields: ["name"],
                    clearable: true,
                    getDataMethod: "data",
                    //url: "/Users/GetSuggestData?type=司机类型&keyword=",
                    data: { value: data },
                    idField: "id",
                    keyField: "name",
                }).on('onDataRequestSuccess', function (e, result) {
                    console.log('onDataRequestSuccess: ', result);
                }).on('onSetSelectValue', function (e, keyword, data) {
                    $("#AgentPeoperUserId").val(data.id);
                    console.log('onSetSelectValue: ', keyword, data);
                }).on('onUnsetSelectValue', function () {
                    console.log('onUnsetSelectValue');
                });
            }
        }
        function blurEmpty2() {
            var cityObj = $("#dropdown-agentpeoperuserid");
            var DriverId = $("#AgentPeoperUserId");
            if (cityObj.val() == "") {
                DriverId.attr("value", "");
            }
        }

        function ReloadAjaxCallbackgoback(data, successInfo) {
            CommonAjaxCallback(data, function () {
                window.location.href = "/Deposit/Examine?id=" + data.result;
            }, successInfo);
        }
    </script>
}
